import { createApp, h, getCurrentInstance } from 'vue';
import testcomponents from '@/addon/shop/pages/test/components/test-components/test-components.vue';
export default {
	install(app) {
		// 打开邀请组件
		app.config.globalProperties.$openInvite = function (params) {
			const container = document.createElement('div');
			const instance = createApp({
				render() {
					return h(testcomponents, { _specia: params });
				}
			});
			const InviteEle = document.body.lastElementChild;
			if (InviteEle && InviteEle.className === 'invite-box') return;
			setTimeout(() => {
				document.body.appendChild(container);
				instance.mount(container);
			});
			return instance;
		};

		// 关闭邀请组件
		app.config.globalProperties.$closeInvite = function () {
			const InviteEle = document.body.lastElementChild;
			if (InviteEle && InviteEle.className === 'invite-box') {
				document.body.removeChild(InviteEle);
			}
		};
	}
};